package com.nitty.cash.loop.weight.toast;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.nitty.cash.loop.R;
import com.nitty.cash.loop.utils.NittyDensityUtil;

/**
 * CustomToast
 * @Author wwdeng
 * @CreateTime: 2024/10/16 10:46
 * @Annotation：自定义Toast
 */
public class CustomToast extends Toast {

	private TextView textView;
	private String text;
	private int time;
	private Context context;

	public CustomToast(Context context, String text, int time) {
		super(context);
		this.context = context;
		this.text = text;
		this.time = time;
		init();
	}

	private void init() {
		View view = View.inflate(context, R.layout.dialog_toast, null);
		setView(view);
		textView = view.findViewById(R.id.textToast);
		textView.setText(text);
		setGravity(Gravity.BOTTOM, 0, NittyDensityUtil.dp2px(32f));
		setDuration(time);
	}
}
